<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Album extends Backend_Controller {

	/**
	 * 构造函数
	 */
	public function __construct() {
		parent::__construct();
		$this->isValidRequest();
		//加载admin模型
		$this->load->model('backend/Album_model', 'Album');
		//加载验证类
		$this->load->library('form_validation');
	}
	
	public function delete() {
		$ids = $this->input->post_get('ids');
		$rows = $this->Album->getAll($ids, 'img');
		
		if(!empty($rows)) {
			foreach ($rows as $v) {
				if(file_exists($v['img'])) {
					unlink($v['img']);
				}
			}
		}
		if ($this->Album->deleteAll($ids)) {
			$this->renderJson(200);
		}
		
		$this->renderJson(300);
	}
	
}